package main 

import "fmt"
import "time"

func main() {

	var intChan = make(chan int, 10)
	for i:=0; i<10; i++ {
		intChan <- i
	}
	// close(intChan)

	var strChan = make(chan string, 5)
	for i:=0; i<5; i++ {
		strChan <- "hello " + fmt.Sprint(i)
	}
	// close(strChan)

	for {
		select {
			case v := <-intChan:
				fmt.Printf("从intChan里读取数据：%v\n", v)
				time.Sleep(time.Millisecond * 100)
			case v:= <- strChan:
				fmt.Printf("从strChan里读取数据：%v\n", v)
				time.Sleep(time.Millisecond * 100)
			default:
				fmt.Printf("数据读取完毕\n")
				// 执行完毕后跳出循环
				return
		}
	}

}